package tdh.dao.Impl;

import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import tdh.dao.DepartDao;
import tdh.entity.po.Depart;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 部门类数据库操作接口实现类
 * @author 曹昊
 * @date 2021/7/12
 */
@Repository("departDao")
public class DepartDaoImpl implements DepartDao {
    @Autowired
    HibernateTemplate hibernateTemplate;

    /**
     * @Author caohao
     * @Description 返回全部的部门列表
     * @Date 10:01 2021/7/12
     * @Param []
     * @return java.util.List<tdh.entity.po.Depart>
     **/
    @Override
    public List<Depart> allDeaprts() {
        ArrayList<Depart> departs = new ArrayList<Depart>();
        List list = hibernateTemplate.find("From tdh.entity.po.Depart");
        for (Iterator iterator = list.iterator();iterator.hasNext();){
            Depart depart = (Depart) iterator.next();
            departs.add(depart);
        }
        return departs;
    }
}
